package com.zhangzeqin.code.controller;

import com.zhangzeqin.code.entity.Word;
import com.zhangzeqin.code.service.Impl.WordServiceImpl;
import com.zhangzeqin.code.service.WordBookService;
import com.zhangzeqin.code.service.WordService;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class WordController {
    /**
     * 实例化一个持久层对象
     */
    WordService wordService=new WordServiceImpl();
    public WordController(){

    }
    /**
     *添加单词
     * @param wordBook 单词书名
     * @param word 单词
     * @param meaning 意思
     * @return 返回一个boolean值
     */
    public boolean addWord(String wordBook,String word,String meaning){
        return wordService.addWord(wordBook,word,meaning);
    }

    /**
     * 删除单词
     * @param wordBook 单词书名
     * @param word 单词
     * @return 返回一个boolean值
     */
    public boolean deleteWord(String wordBook,String word){
        return wordService.deleteWord(wordBook,word);
    }

    /**
     * 修改单词
     * @param wordBook 单词书名
     * @param word    原单词
     * @param meaning 意思
     * @return 返回一个boolean值
     */
    public boolean modifyWord(String wordBook,String meaning,String word){
        return wordService.modifyWord(wordBook,meaning,word);
    }

    /**
     * 查找单词
     * @param wordBook 单词书名
     * @param word 单词
     * @param meaning 意思
     * @return 返回一个boolean值
     */
    public List<Map> checkWord(String wordBook, String word, String meaning) throws SQLException{
        return wordService.checkWord(wordBook,word,meaning);
    }
}
